package ATM;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class PassWordModifyJpanel extends JPanel implements ActionListener {
    private Icon buttonModify = Util.getimagesIcon("/images/buttonModify.jpg");
    private Icon buttonOff = Util.getimagesIcon("/images/buttonOff.jpg");
    private JLabel jLabelModify;
    private JButton jButtonModify;
    private JTextField jTextFieldModify;
    private JButton btnOff;
    private ATMJframe atmJframe;

    public PassWordModifyJpanel(ATMJframe atmJframe) {
        this.atmJframe = atmJframe;
        this.setLayout(null);
        this.setOpaque(false);
        jLabelModify = new JLabel("请输入新密码：");
        jLabelModify.setBounds(300, 200, 250, 50);
        jLabelModify.setFont(new Font("宋体", Font.BOLD, 25));
        this.add(jLabelModify);

        jTextFieldModify = new JTextField();
        jTextFieldModify.setBounds(520, 200, 300, 50);
        jTextFieldModify.setFont(new Font("宋体", Font.BOLD, 25));
        this.add(jTextFieldModify);

        jButtonModify = new JButton("", buttonModify);
        jButtonModify.setBounds(300, 250, 140, 50);
        this.add(jButtonModify);
        jButtonModify.addActionListener(this);


        btnOff = new JButton("", buttonOff);
        btnOff.setBounds(850, 550, 140, 50);
        this.add(btnOff);
        btnOff.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == btnOff) {
            atmJframe.switchPanel("menu");
        } else if (e.getSource() == jButtonModify) {
            atmJframe.getUser().setPassWord(jTextFieldModify.getText());
            JOptionPane.showMessageDialog(this, "修改密码成功");


        }
    }
}

